
// const CompressionPlugin = require('compression-webpack-plugin');
// console.log(CompressionPlugin)
const __DEV__ = process.env.NODE_ENV === 'development'

const proxy = {}
// http://117.24.14.83:9010
const axios = {
  proxy: true,
  baseURL: 'http://test.333ks.cn/api',
  // baseURL: 'http://test.333ks.cn',
  browserBaseURL: '/api/'
}

proxy['/api'] = {
  target: 'http://test.333ks.cn/',
  headers: {
    host: 'test.333ks.cn'
  },
  changeOrigin: true,
}

// 调试环境，统一请求localhost
// if (__DEV__) {
  // axios.baseURL = 'http://localhost:8998/api'
  // axios.browserBaseURL = 'http://localhost:8998/api'
//   proxy['/api'] = {
//     target: 'http://test.333ks.cn/',
//     headers: {
//       host: 'test.333ks.cn'
//     }
//   }
// }

module.exports = {
  mode: 'universal',
  /*
   ** Headers of the page
   */
  head: {
    meta: [
      { charset: 'utf-8' },
      { name: 'renderer', content: 'webkit' },
      {
        hid: 'keywords',
        name: 'keywords',
        content:
          '平台,低价平台,平台,搭建平台,平台代理,平台平台,平台代理,平台排行榜,平台排行榜第一,平台系统,搭建平台,做平台'
      }
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
    script: [
      // {
      //   src: '/jquery-1.9.0.min.js'
      // }
    ]
  },
  /*
   ** Customize the progress-bar color
   */
  loading: { color: '#fff' },
  /*
   ** Global CSS
   */
  css: [
    // '@/static/iconfont.css'
  ],
  router: {
    // 服务中间件，最优先执行
    middleware: ['siteBydomain']
  },
  /*
   ** Plugins to load before mounting the App
   */
  plugins: ['@/plugins/axios',
            '@/plugins/index',
            // {src:"~/plugins/vconsole", ssr: false},
            { src: '~/plugins/element-ui', ssr: true },
            //'@/plugins/router'
            // {src:'~/plugins/storeCache',ssr: false},

            ],
  /*
   ** Nuxt.js dev-modules
   */
  buildModules: [
    // Doc: https://github.com/nuxt-community/eslint-module
    // '@nuxtjs/eslint-module'
  ],
  /*
   ** Nuxt.js modules
   */
  modules: [
    'cookie-universal-nuxt',
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/style-resources',
    '@nuxtjs/proxy'
  ],
  /*
   ** Axios module configuration
   ** See https://axios.nuxtjs.org/options
   */
  axios,
  proxy,
  /*
   ** Build configuration
   */
  build: {
    // maxChunkSize: 400000,
    optimization: {
      splitChunks: {
        minSize: 10000,
        maxSize: 800000
      }
    },
    transpile: [
      /^element-ui/,  // /^vant/
    ],
    splitChunks: {
      layouts: true,
      cache: true,
      parallel: true,
    },
    extractCSS: !__DEV__,
    babel: {
      plugins: [
        [ "component", {"libraryName": "element-ui",  "styleLibraryName": "theme-chalk"}]
      ]
    },
    plugins: [
    ],
    // 开启打包分析
    analyze: true,
    assetFilter: function(assetFilename) {
      return assetFilename.endsWith('.js');
    },

    /*
     ** You can extend webpack config here
     */
    extend(config, ctx) {
      config.node = {
        "fs": false,
        "path": false,
        "os": false
      }
      return config
    }
  },
  styleResources: {
    scss: ['./assets/variables.scss']
  },
  server: {
    port: 9998
  },

  ssr: true,
  render: {
    ssr: true,
  }
}
